import React, { Component } from 'react';
import { ScrollView, View, Text } from 'react-native';
import CellItem from '../../views/cellItem';
import CheckStateItem from '../../views/checkStateItem';
import CellTitleItem from '../../views/cellTitleItem';
import SerialsItem from '../../views/serialsItem';
import GoodItem from '../../views/goodItem';

import { connect } from 'react-redux';
class CodeDetail extends Component() {
    constructor(props) {
        super(props);
        this.data = {
            codeList:null,
            gooodsItem:null,
        }
    }
    componentDidMount() {
        const { navigation } = this.props;
        const codeList = JSON.parse(navigation.getParam("codeList"));
        const RecId = navigation.getParam("RecId");
        this.setState({
            gooodsItem: item,
            RecId: RecId,
        })
    }
    _renderSerials(item, index, length) {
        const noBorder = index == length - 1 ? true : false;
        return (
            <SerialsItem value={item.BarCode} noBorder={noBorder} />
        )
    }
    render() {
        return (
            <ScrollView style={styles.container}>
                <View style={Style.aic}>
                    <CellTitleItem title="入库商品" />
                    {
                        this.state.gooodsItem ?
                            <GoodItem
                                source={gooodsItem.images[0]}
                                name={gooodsItem.Name}
                                key={gooodsItem.name}
                                showAngle={false}
                                detailList={gooodsItem.detailList}
                                pressItem={() => { return }}
                                noBorder={true}
                            /> : null
                    }
                    <View style={[Style.gap, Style.gapTop]} />
                    {
                        codeList && codeList.length > 0 ?
                            <View>
                                <CellTitleItem title="已入库序列号" />
                                <View>
                                    {
                                        codeList.map((item, index) => this._renderSerials(item, index, codeList.length))
                                    }
                                </View>
                            </View> : null
                    }
                    <View style={Style.bottom}></View>
                </View>
            </ScrollView>
        )
    }
}
const styles = StyleSheet.create({
    container: {
        width: Style.width,
        height: Style.ViewHeightD,
        backgroundColor: '#fff',
    },
    mt: {
        marginTop: 20
    },
    textWrap: {
        width: Style.width,
        height: 150,
        borderColor: '#e5e5e5',
        borderStyle: 'solid',
        borderTopWidth: 1,
        borderBottomWidth: 1,
        marginBottom: 20,

    },
    textInput: {
        padding: 10,
    },
})
export default connect()(CodeDetail)